/*
 * RemoveArcCommand.java
 *
 * Created on 12 czerwiec 2007, 00:19
 */

package edu.uj.petri.commands;

import edu.uj.petri.document.Document;
import edu.uj.petri.view.ArcView;
import java.util.ResourceBundle;

/**
 *
 * @author Paweł
 */
public class RemoveArcCommand extends Command {
    
    private ArcView arcView;
    private Memento memento;
    private Memento beginMemento;
    private Memento endMemento;
    private Memento redoBeginMemento;
    private Memento redoEndMemento;
    private boolean firstTime=true;
        
    public RemoveArcCommand( ArcView arcView) {
        
        this.arcView = arcView;
    }

    public String toString() {
        
        return ResourceBundle.getBundle("edu/uj/petri/messages").getString("remove_edge");
    }

    void execute() {
         if (firstTime) {
            memento = arcView.getMemento();
            
            arcView.removeFrom( Document.getActiveDocument().getView() );
            firstTime = false;
        } else {
            arcView.removeFrom( Document.getActiveDocument().getView() );
        }
        
    }

    void undo() {
        
        arcView.applyMemento(memento);
        Document.getActiveDocument().getView().addElement(arcView);
    }

    boolean canBeCombined(Command c) {
        
        return false;
    }

    private static final long serialVersionUID = 2576716145121659470L;
    
}
